
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>5.1 帖子分类 · Laravel学习-从零开发论坛系统</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="kaleozhou">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2.html" />
    
    
    <link rel="prev" href="readme.html" />
    

    
        <link rel="shortcut icon" href='../book.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../book.ico' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../book.ico'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../book.ico">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../book.ico">
        
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.kaleozhou.top" target="_blank" class="custom-link">我的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    序言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1/1.html">
            
                <a href="../chapter1/1.html">
            
                    
                    第一章 开发环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter2/readme.html">
            
                <a href="../chapter2/readme.html">
            
                    
                    第二章 创建应用及布局
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter2/1.html">
            
                <a href="../chapter2/1.html">
            
                    
                    2.1 创建应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter2/2.html">
            
                <a href="../chapter2/2.html">
            
                    
                    2.2 创建布局文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter2/3.html">
            
                <a href="../chapter2/3.html">
            
                    
                    2.3 创建首页展示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter2/4.html">
            
                <a href="../chapter2/4.html">
            
                    
                    2.4 调整样式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/readme.html">
            
                <a href="../chapter3/readme.html">
            
                    
                    第三章 laravel组件的使用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/1.html">
            
                <a href="../chapter3/1.html">
            
                    
                    3.1 用户脚手架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/2.html">
            
                <a href="../chapter3/2.html">
            
                    
                    3.2 注册验证码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter3/3.html">
            
                <a href="../chapter3/3.html">
            
                    
                    3.3 邮箱验证
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter3/4.html">
            
                <a href="../chapter3/4.html">
            
                    
                    3.4 密码重置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter4/readme.html">
            
                <a href="../chapter4/readme.html">
            
                    
                    第四章 基础功能开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter4/1.html">
            
                <a href="../chapter4/1.html">
            
                    
                    4.1 个人页面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter4/2.html">
            
                <a href="../chapter4/2.html">
            
                    
                    4.2 编辑个人资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter4/3.html">
            
                <a href="../chapter4/3.html">
            
                    
                    4.3 显示个人资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter4/4.html">
            
                <a href="../chapter4/4.html">
            
                    
                    4.4 上传头像
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="readme.html">
            
                <a href="readme.html">
            
                    
                    第五章 帖子功能开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.6.1" data-path="1.html">
            
                <a href="1.html">
            
                    
                    5.1 帖子分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="2.html">
            
                <a href="2.html">
            
                    
                    5.2 代码生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="3.html">
            
                <a href="3.html">
            
                    
                    5.3 生成话题骨架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="4.html">
            
                <a href="4.html">
            
                    
                    5.4 假数据填充
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="5.html">
            
                <a href="5.html">
            
                    
                    5.5 话题列表页面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="6.html">
            
                <a href="6.html">
            
                    
                    5.6 性能优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="7.html">
            
                <a href="7.html">
            
                    
                    5.7 分类下的话题列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="8.html">
            
                <a href="8.html">
            
                    
                    5.8 话题排序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="9.html">
            
                <a href="9.html">
            
                    
                    5.9 用户发布的话题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter6/readme.html">
            
                <a href="../chapter6/readme.html">
            
                    
                    第六章 话题开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter6/1.html">
            
                <a href="../chapter6/1.html">
            
                    
                    6.1 新建话题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/2.html">
            
                <a href="../chapter6/2.html">
            
                    
                    6.2 编辑器优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter6/3.html">
            
                <a href="../chapter6/3.html">
            
                    
                    6.3 上传图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter6/4.html">
            
                <a href="../chapter6/4.html">
            
                    
                    6.4 显示帖子
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter6/5.html">
            
                <a href="../chapter6/5.html">
            
                    
                    6.5 XSS安全漏洞
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter6/6.html">
            
                <a href="../chapter6/6.html">
            
                    
                    6.6 编辑帖子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >5.1 帖子分类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;"><b></b>5.1 &#x5E16;&#x5B50;&#x5206;&#x7C7B;</a></li><ul><li><span class="title-icon "></span><a href="#&#x8BF4;&#x660E;"><b></b>&#x8BF4;&#x660E;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x636E;&#x6A21;&#x578B;"><b></b>&#x6570;&#x636E;&#x6A21;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x636E;&#x6A21;&#x578B;_1"><b></b>&#x6570;&#x636E;&#x6A21;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;"><b></b>&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;</a></li></ul></ul></div><a href="#51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;"><a name="51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;" class="plugin-anchor" href="#51-&#x5E16;&#x5B50;&#x5206;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>5.1 &#x5E16;&#x5B50;&#x5206;&#x7C7B;</h1>
<h2 id="&#x8BF4;&#x660E;"><a name="&#x8BF4;&#x660E;" class="anchor-navigation-ex-anchor" href="#&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x8BF4;&#x660E;" class="plugin-anchor" href="#&#x8BF4;&#x660E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8BF4;&#x660E;</h2>
<p>&#x5728;&#x6211;&#x4EEC;&#x5F00;&#x53D1;&#x5E16;&#x5B50;&#x4E4B;&#x524D;&#xFF0C;&#x9700;&#x8981;&#x51C6;&#x5907;&#x597D;&#x5E16;&#x5B50;&#x5206;&#x7C7B;&#xFF0C;&#x56E0;&#x4E3A;&#x6BCF;&#x4E00;&#x7BC7;&#x5E16;&#x5B50;&#x90FD;&#x5FC5;&#x987B;&#x53D1;&#x5E03;&#x5728;&#x67D0;&#x4E00;&#x4E2A;&#x5206;&#x7C7B;&#x4E0B;&#x9762;&#xFF0C;&#x5E16;&#x5B50;&#x4F9D;&#x8D56;&#x4E8E;&#x5206;&#x7C7B;&#x3002;
&#x6211;&#x4EEC;&#x5C06;&#x4F1A;&#x4E3A;kaleobbs&#x51C6;&#x5907;&#x4E00;&#x4E0B;&#x5206;&#x7C7B;:</p>
<ul>
<li>&#x5206;&#x4EAB;</li>
<li>&#x6559;&#x7A0B;</li>
<li>&#x95EE;&#x7B54;</li>
<li>&#x516C;&#x544A;</li>
</ul>
<h2 id="&#x6570;&#x636E;&#x6A21;&#x578B;"><a name="&#x6570;&#x636E;&#x6A21;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x636E;&#x6A21;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6570;&#x636E;&#x6A21;&#x578B;" class="plugin-anchor" href="#&#x6570;&#x636E;&#x6A21;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x636E;&#x6A21;&#x578B;</h2>
<p>&#x6211;&#x4EEC;&#x9700;&#x8981;&#x521B;&#x5EFA;&#x3010;&#x5206;&#x7C7B;&#x6A21;&#x578B;&#x3011;&#x6765;&#x8DDF;&#x6570;&#x636E;&#x5E93;&#x8FDB;&#x884C;&#x4EA4;&#x4E92;&#xFF0C;&#x7528;&#x5982;&#x4E0B;&#x547D;&#x4EE4;:</p>
<pre><code>vagrant@homestead:~/Code/kaleobbs$ php artisan make:model Models/Category -m
Model created successfully.
Created Migration: 2019_04_14_091133_create_categories_table
</code></pre><p>&#x4FEE;&#x6539;&#x8FC1;&#x79FB;&#x6587;&#x4EF6;:</p>
<pre><code>&#x279C; kaleo@zhou  ~/Code/kaleobbs git:(master) &#x2717; vim database/migrations/2019_04_14_091133_create_categories_table.php
</code></pre><p>&#x5185;&#x5BB9;&#x5982;&#x4E0B;:</p>
<pre><code>&lt;?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create(&apos;categories&apos;, function (Blueprint $table) {
            $table-&gt;increments(&apos;id&apos;);
            $table-&gt;string(&apos;name&apos;)-&gt;index()-&gt;comment(&apos;&#x540D;&#x79F0;&apos;);
            $table-&gt;text(&apos;description&apos;)-&gt;nullable()-&gt;comment(&apos;&#x63CF;&#x8FF0;&apos;);
            $table-&gt;integer(&apos;post_count&apos;)-&gt;default(0)-&gt;comment(&apos;&#x5E16;&#x5B50;&#x6570;&apos;);
            $table-&gt;timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(&apos;categories&apos;);
    }
}
</code></pre><p>&#x8FD0;&#x884C;&#x4E00;&#x4E0B;&#x547D;&#x4EE4;&#x6267;&#x884C;&#x8FC1;&#x79FB;:</p>
<pre><code>vagrant@homestead:~/Code/kaleobbs$ php artisan migrate
Migrating: 2019_04_14_091133_create_categories_table
Migrated:  2019_04_14_091133_create_categories_table
</code></pre><h2 id="&#x6570;&#x636E;&#x6A21;&#x578B;_1"><a name="&#x6570;&#x636E;&#x6A21;&#x578B;_1" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x636E;&#x6A21;&#x578B;_1"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x6570;&#x636E;&#x6A21;&#x578B;" class="plugin-anchor" href="#&#x6570;&#x636E;&#x6A21;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6570;&#x636E;&#x6A21;&#x578B;</h2>
<p>&#x6BCF;&#x5F53;&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x5B8C;&#x6570;&#x636E;&#x6A21;&#x578B;&#x4E4B;&#x540E;&#xFF0C;&#x90FD;&#x9700;&#x8981;&#x8BBE;&#x7F6E;Category&#x7684;$fileable&#x767D;&#x540D;&#x5355;&#x5C5E;&#x6027;,&#x544A;&#x8BC9;&#x7A0B;&#x5E8F;&#x90A3;&#x4E9B;&#x5B57;&#x6BB5;&#x662F;&#x652F;&#x6301;&#x4FEE;&#x6539;&#x7684;:</p>
<pre><code>&lt;?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    //
    protected $fileable=[
        &apos;name&apos;,&apos;description&apos;,
    ];
}
</code></pre><h2 id="&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;"><a name="&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;" class="anchor-navigation-ex-anchor" href="#&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;" class="plugin-anchor" href="#&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521D;&#x59CB;&#x5316;&#x5206;&#x7C7B;&#x6570;&#x636E;</h2>
<p>&#x6211;&#x4EEC;&#x60F3;&#x8981;&#x8BBA;&#x575B;&#x8F6F;&#x4EF6;&#x5728;&#x5B89;&#x88C5;&#x65F6;&#xFF0C;&#x5C31;&#x521D;&#x59CB;&#x5316;&#x672C;&#x6587;&#x6700;&#x524D;&#x9762;&#x63D0;&#x5230;&#x7684;&#x56DB;&#x4E2A;&#x5206;&#x7C7B;&#x3002;
&#x9762;&#x5BF9;&#x6570;&#x636E;&#x5E93;&#x5185;&#x5BB9;&#x586B;&#x5145;&#x9700;&#x6C42;&#xFF0C;&#x6211;&#x4EEC;&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#x4F1A;&#x4F7F;&#x7528;Laravel&#x7684;&#x3010;&#x6570;&#x636E;&#x586B;&#x5145;Seed&#x3011;&#x3002;&#x53EF;&#x662F;&#x5728;&#x5F53;&#x4E0B;&#x573A;&#x666F;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x65E0;&#x6CD5;&#x4F7F;&#x7528;&#x6B64;&#x529F;&#x80FD;&#xFF0C;&#x6B64;&#x4E00;&#x822C;&#x662F;&#x7528;&#x6765;&#x751F;&#x6210;&#x5047;&#x6570;&#x636E;&#xFF0C;&#x800C;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x751F;&#x6210;&#x7684;&#x662F;&#x9879;&#x76EE;&#x7684;&#x521D;&#x59CB;&#x5316;&#x6570;&#x636E;&#xFF0C;
&#x8FD9;&#x4E9B;&#x6570;&#x636E;&#x662F;&#x9879;&#x76EE;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E0B;&#x4E5F;&#x4F1A;&#x4F7F;&#x7528;&#x5230;&#xFF0C;&#x800C;&#x6570;&#x636E;&#x586B;&#x5145;&#x53EA;&#x80FD;&#x5728;&#x5F00;&#x53D1;&#x65F6;&#x4F7F;&#x7528;&#x3002;
&#x867D;&#x7136;Laravel&#x6CA1;&#x6709;&#x81EA;&#x5E26;&#x6B64;&#x7C7B;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#xFF0C;&#x4E0D;&#x8FC7;&#x6570;&#x636E;&#x8FC1;&#x79FB;&#x529F;&#x80FD;&#x5230;&#x65F6;&#x53EF;&#x4EE5;&#x66FF;&#x4EE3;&#x7684;&#x65B9;&#x6848;&#x3002;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x547D;&#x4EE4;&#x6765;&#x751F;&#x6210;&#x8FC1;&#x79FB;&#x6587;&#x4EF6;&#xFF0C;&#x4F5C;&#x4E3A;&#x521D;&#x59CB;&#x5316;&#x6570;&#x636E;&#x7684;&#x8FC1;&#x79FB;&#x6587;&#x4EF6;&#x3002;</p>
<pre><code>vagrant@homestead:~/Code/kaleobbs$ php artisan make:migration seed_categories_data
Created Migration: 2019_04_14_122835_seed_categories_data
</code></pre><p>&#x4FEE;&#x6539;&#x8BE5;&#x6587;&#x4EF6;&#x5982;&#x4E0B;:</p>
<pre><code>&lt;?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class SeedCategoriesData extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $categories=[
            [
                &apos;name&apos; =&gt; &apos;&#x5206;&#x4EAB;&apos;,
                &apos;description&apos; =&gt; &apos;&#x5206;&#x4EAB;&#x521B;&#x9020;&#xFF0C;&#x5206;&#x4EAB;&#x53D1;&#x73B0;&apos;,
            ],
            [
                &apos;name&apos; =&gt; &apos;&#x6559;&#x7A0B;&apos;,
                &apos;description&apos; =&gt; &apos;&#x5F00;&#x53D1;&#x6280;&#x5DE7;&#xFF0C;&#x63A8;&#x8350;&#x6269;&#x5C55;&#x5305;&#x7B49;&apos;,
            ],
            [
                &apos;name&apos; =&gt; &apos;&#x95EE;&#x7B54;&apos;,
                &apos;description&apos; =&gt; &apos;&#x8BF7;&#x4FDD;&#x6301;&#x53CB;&#x5584;&#xFF0C;&#x4E92;&#x76F8;&#x5E2E;&#x52A9;&apos;,
            ],
            [
                &apos;name&apos; =&gt; &apos;&#x516C;&#x544A;&apos;,
                &apos;description&apos; =&gt; &apos;&#x7AD9;&#x70B9;&#x516C;&#x544A;&apos;,
            ],
        ];
        DB:table(&apos;categories&apos;)-&gt;insert($categories);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB:table(&apos;categories&apos;)-&gt;truncate();
    }
}
</code></pre><p>&#x6267;&#x884C;&#x8FC1;&#x79FB;&#x547D;&#x4EE4;:</p>
<pre><code>vagrant@homestead:~/Code/kaleobbs$ php artisan migrate
Migrating: 2019_04_14_122835_seed_categories_data
Migrated:  2019_04_14_122835_seed_categories_data
</code></pre><p>&#x67E5;&#x770B;&#x662F;&#x5426;&#x6210;&#x529F;:
<img src="http://images.kaleozhou.top/5.1-01.png" alt="5.1-01.png"></p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; kaleozhou 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2019-05-20 16:16:56
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="readme.html" class="navigation navigation-prev " aria-label="Previous page: 第五章 帖子功能开发">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="2.html" class="navigation navigation-next " aria-label="Next page: 5.2 代码生成器">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"5.1 帖子分类","level":"1.6.1","depth":2,"next":{"title":"5.2 代码生成器","level":"1.6.2","depth":2,"path":"chapter5/2.md","ref":"chapter5/2.md","articles":[]},"previous":{"title":"第五章 帖子功能开发","level":"1.6","depth":1,"path":"chapter5/readme.md","ref":"chapter5/readme.md","articles":[{"title":"5.1 帖子分类","level":"1.6.1","depth":2,"path":"chapter5/1.md","ref":"chapter5/1.md","articles":[]},{"title":"5.2 代码生成器","level":"1.6.2","depth":2,"path":"chapter5/2.md","ref":"chapter5/2.md","articles":[]},{"title":"5.3 生成话题骨架","level":"1.6.3","depth":2,"path":"chapter5/3.md","ref":"chapter5/3.md","articles":[]},{"title":"5.4 假数据填充","level":"1.6.4","depth":2,"path":"chapter5/4.md","ref":"chapter5/4.md","articles":[]},{"title":"5.5 话题列表页面","level":"1.6.5","depth":2,"path":"chapter5/5.md","ref":"chapter5/5.md","articles":[]},{"title":"5.6 性能优化","level":"1.6.6","depth":2,"path":"chapter5/6.md","ref":"chapter5/6.md","articles":[]},{"title":"5.7 分类下的话题列表","level":"1.6.7","depth":2,"path":"chapter5/7.md","ref":"chapter5/7.md","articles":[]},{"title":"5.8 话题排序","level":"1.6.8","depth":2,"path":"chapter5/8.md","ref":"chapter5/8.md","articles":[]},{"title":"5.9 用户发布的话题","level":"1.6.9","depth":2,"path":"chapter5/9.md","ref":"chapter5/9.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","donate","sharing-plus","anchor-navigation-ex","tbfed-pagefooter","favicon"],"styles":{"website":"./styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy kaleozhou 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"github":{"url":"https://gitee.com/kaleozhou"},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"http://images.kaleozhou.top/zanshang.png","alipayText":" ","button":"赞赏","title":"","wechat":"","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./book.ico","bookmark":"./book.ico","appleTouch":"./book.ico","appleTouchMore":{"120x120":"./book.ico","180x180":"./book.ico"}},"github-buttons":{"buttons":[{"user":"kaleozhou","repo":"guanwang","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":true,"all":["weibo","qq","qzone"],"douban":true,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":true,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"theme":"default","author":"kaleozhou","pdf":{"pageBreaksBefore":"/","paperSize":"a4","margin":{"right":30,"left":30,"top":30,"bottom":50},"fontSize":18,"pageSize":"a4","fontFamily":"Arial","doc":true,"chapterMark":"pagebreak","pageNumbers":true},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Laravel学习-从零开发论坛系统","language":"zh-hans","links":{"sidebar":{"我的博客":"http://www.kaleozhou.top"}},"gitbook":"3.2.3","description":"laravel框架开发论坛系统"},"file":{"path":"chapter5/1.md","mtime":"2019-05-20T08:16:56.851Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-25T02:56:39.861Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

